package cn.edu.tjufe.llp.tin.dto.sys;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import cn.edu.tjufe.llp.tin.model.sys.SysUser;


@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface SysUserMapper {
	SysUserMapper INSTANCE = Mappers.getMapper(SysUserMapper.class);
	

	SysUser toEntityWithRoles(SysUserDto sysUserDto);

	@Mapping(target = "roles", ignore = true)
	SysUser toEntityWithoutRoles(SysUserDto sysUserDto);

	// @InheritInverseConfiguration
	SysUserDto toDtoWithRoles(SysUser customer);

	@Mapping(target = "roles", ignore = true)
	SysUserDto toDtoWithoutRoles(SysUser customer);
	
	// mapstruct-reference-guide.pdf(page.17)
	// Updating existing bean instances，两种返回值类型：
	SysUser updateEntityWithRoles(SysUserDto sysUserDto, @MappingTarget SysUser sysUser);
	// void updateSysUserFromDto(SysUserDto sysUserDto, @MappingTarget SysUser sysUser);

	@Mapping(target = "roles", ignore = true)
	SysUser updateEntityWithoutRoles(SysUserDto sysUserDto, @MappingTarget SysUser sysUser);

}